<template>
  <transition name="uploading" appear>
    <div class="up-loading-box" v-show="show" @click="closeLoading">
      <div class="up-loading">
        <img class="loading-img" src="../assets/img/icon_loading.png" alt="" srcset="" />
        <span class="up-loading-text">{{ loadingText }}</span>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  data () {
    return {
      show: false,
      loadingText: '加载中...',
      isAllowClose: false
    }
  },
  methods: {
    closeLoading () {
      if (this.isAllowClose) {
        this.show = false
      }
    }
  }
}
</script>

<style lang="less">
.up-loading-box {
  height: 100vh;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}

.up-loading {
  width: 120px;
  height: 120px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background-color: #000;
  border-radius: 10px;
  filter: alpha(opacity=60);
  /*IE滤镜，透明度50%*/-moz-opacity: 0.6;
  /*Firefox私有，透明度50%*/opacity: 0.6;
  /*其他，透明度50%*/
  box-sizing: border-box;
  z-index: 1000;
  -webkit-filter: alpha(opacity=60);
}

.up-loading-text {
  font-size: 14px;
  color: #fff;
}

.loading-img {
  display: block;
  margin: 25px auto 0;
  width: 40px;
  height: 40px;
  animation: spinning 1s infinite linear;
}

@keyframes spinning {
  0% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(180deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.uploading-enter-active, .upoverlay-leave-active {
  transition: opacity 0.6s;
}
.uploading-enter, .upoverlay-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
</style>
